package com.siti.kindnessplatform.donate.mapper;

import com.siti.kindnessplatform.donate.vo.DonateVo;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;


public interface DonateMapper {

    @Select({"SELECT headline,DATE_FORMAT(pubdate,'%Y-%m-%d %H:%i:%s') pubDate,main_body mainBody,publish_source publishSource," +
            "url,vacancy,is_top*1 isTop,IF(TIMESTAMPDIFF(HOUR,pubdate,CURRENT_TIMESTAMP())<1," +
            "concat(TIMESTAMPDIFF(MINUTE, pubdate, CURRENT_TIMESTAMP()),'分钟前'),IF(DATE(pubdate)=CURRENT_DATE()," +
            "concat(TIMESTAMPDIFF(HOUR,pubdate,CURRENT_TIMESTAMP()),'小时前'),concat(DATEDIFF(CURRENT_TIMESTAMP(),pubdate),'天前'))) duration," +
            "IF(d.pubdate=mxd.maxDate,1,null) isNew FROM donate d,(SELECT MAX(pubdate) maxDate FROM donate) mxd" +
            " ORDER BY is_top DESC,pubdate DESC"})
    List<DonateVo> getDonateInfo();

}
